Post

Replies

Boosts

Views

Activity

Testing the content of a `Task` in a non-async method
Hi, Considering this method I'd like to test: public func play(_ soundFileName: String, shouldLoop: Bool) { Task { await dataSource.play(soundFileName, shouldLoop: shouldLoop) } } Previously, with XCTest we could use an expectation and wait for it to be fulfilled: func test() sut.play("", shouldLoop: false) wait(for: [mockedAudioPlayerDataSource.invokedPlayExpectation]) XCTAssertEqual(mockedAudioPlayerDataSource.invokedPlayCount, 1) With Swift Testing, I am unsure what a unit test looks like.
4
0
299
Oct ’24